import requests
import re
from tqdm import tqdm

headers = {
    'accept': '*/*',
    'accept-language': 'zh-CN,zh;q=0.9',
    'origin': 'https://kimivod.org',
    'priority': 'u=1, i',
    'referer': 'https://kimivod.org/',
    'sec-ch-ua': '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'cross-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
}


if __name__ == '__main__':
    response = requests.get('https://m3u8.hmrvideo.com/play/5862d5441fe5418b8031cb930c0da3a2.m3u8', headers=headers)
    yi = re.findall(r',\n(.*?)\n#', response.text)

    for i in tqdm(yi):
        with open("movie//" + "yi" +".mp4" ,mode= "ab") as f:
            f.write(requests.get(i).content)
    f.close()
    print(response.text)